﻿@model IEnumerable<FinalOpdracht.Models.UserProfile>

@{
    ViewBag.Title = "Blog - NewRole";
}

<h2>Adminpanel</h2>
<br />
<div class="CSSTableGenerator" >
	<table >
		<tr> 
			<td>Role</td>
            <td> </td>
		</tr>
        @foreach (var Role in ViewBag.AllRoles){
            <tr>
                <td>@Html.DisplayFor(r => Role)</td>
                <td>
                    @using (Html.BeginForm())
                    {
                        @Html.HiddenFor(r => Role);
                        <input type="submit" value="Verwijderen" />
                    }
                </td>
            </tr>
        }
	</table>
</div>
<br />
<strong>Role toevoegen:</strong>
@using (@Html.BeginForm())
{
    @Html.TextBox("NewRole")
    <input type="submit" value="Voeg toe" />
}
<br />
<div class="CSSTableGenerator" >
	<table >
		<tr> 
			<td>Gebruikersnaam</td>
			<td>Role</td>
			<td>Bewerken</td>
		</tr>
        @foreach (var user in Model)
        {
            var RoleForUser = new List<string>(Roles.GetRolesForUser(user.UserName));
            
            <tr>
                <td>@Html.DisplayFor(modelItem => user.UserName)</td>
                <td>
                    @foreach (var UserRole in RoleForUser)
                    {
                        @Html.DisplayFor(r => UserRole)
                   }
               </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id=user.UserId })
                </td>
            </tr>
        }
	</table>
</div>